package com.mac.sys.generator;

import java.io.File;
import java.io.FileWriter;

public class FileUtils {
    /**
     * 把生成的文件都保存.
     * @param path
     * @param data
     */
    public static void save(String path, String data) {
        try {
            //生产父文件夹
            File file = new File(path);
            File fileParent = file.getParentFile();
            if(!fileParent.exists()){
                fileParent.mkdirs();
            }


            FileWriter out = new FileWriter(file);
            out.write(data);
            out.flush();
            out.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args)
    {
        File file = new File("E:\\workspace-macsite\\demo\\src\\main\\resources\\views\\qingguo\\store\\store\\store\\store\\list.html");
        File fileParent = file.getParentFile();
        if(!fileParent.exists()){
            fileParent.mkdirs();
        }
    }
}

